import requests
from lxml import etree
q = []
def main():
    un = input('请输入图片id:')
    res = requests.get('http://www.wn01.lol/photos-index-page-1-aid-{au}.html'.format(au=un)).text
    ys = etree.HTML(res)
    p = ys.xpath('//*[@id="bodywrap"]/div[2]/div/div/div[1]/a[5]/text()')[0]
    print(p)
    for i in range(1, int(p)+1):
    # for i in range(1, 5):
        o = 'http://www.wn01.lol/photos-index-page-' + str(i) + '-aid-{au}.html'.format(au=un)
        res1 = requests.get(o).text
        ys1 = etree.HTML(res1)
        if i == 1:
            p = ys1.xpath('//*[@id="bodywrap"]/div[2]/div/ul/li/div/div/span/text()')[1:]
            q.extend(p)
        else:
            p = ys1.xpath('//*[@id="bodywrap"]/div[2]/div/ul/li/div/div/span/text()')
            q.extend(p)
            print('正在获取第{j}页图片链接'.format(j=i))
    # print('图片名称为' + q)
    return q, un
if __name__ == '__main__':
    main()
